#include "smallwidget.h"
#include "ui_smallwidget.h"

SmallWidget::SmallWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SmallWidget)
{
    ui->setupUi(this);

    // Spinbox 动，Slider跟着动

   //[signal] void QSpinBox::valueChanged(int i)
   void (QSpinBox:: *spinValueChanged)(int) = &QSpinBox::valueChanged;
   connect(ui->spinBox, spinValueChanged, ui->horizontalSlider, &QSlider::setValue);

   // 动，Slider动 Spinbox 数字改变

  //[signal] void QSpinBox::valueChanged(int i)
  connect(ui->horizontalSlider, &QAbstractSlider::valueChanged, ui->spinBox, &QSpinBox::setValue);
}

SmallWidget::~SmallWidget()
{
    delete ui;
}

int SmallWidget::getNum()
{
    return ui->spinBox->value();
}

void SmallWidget::setNum(int num)
{
     return ui->spinBox->setValue(num);
}
